package cc.comac.mom.datahandlers.entity;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cc.comac.mom.dao.entity.QualityQarConditionalSentMaterielDao;
import cc.comac.mom.entity.QualityQarConditionalSentMaterielEntity;
import cc.comac.mom.util.BaseEntityDataUtil;
import cc.comac.mom.util.ResultBean;

@Component
public class QualityQarConditionalSentMaterielDataHandler extends ServiceImpl<QualityQarConditionalSentMaterielDao, QualityQarConditionalSentMaterielEntity>{
	
	@Autowired
	private QualityQarConditionalSentMaterielDao qualityQarConditionalSentMaterielDao;
	@Autowired
	private BaseEntityDataUtil baseEntityDataUtil;
	public ResultBean insertConditionalSentMateriel(QualityQarConditionalSentMaterielEntity entity) {
		ResultBean resultBean = new ResultBean();
		if (StringUtils.isEmpty(entity.getQarNumber())) {
			resultBean.setErrorMessge("qar编号不能为空！");
			return resultBean;
		}
		if (StringUtils.isEmpty(entity.getConditionalSentMaterielNo())) {
			resultBean.setErrorMessge("有条件发料编号不能为空！");
			return resultBean;
		}
		if (StringUtils.isEmpty(entity.getPiId())) {
			resultBean.setErrorMessge("pi_id不能为空！");
			return resultBean;
		}
		if (StringUtils.isEmpty(entity.getQty())) {
			resultBean.setErrorMessge("数量不能为空！");
			return resultBean;
		}
		baseEntityDataUtil.setBaseEntityData(entity);
		qualityQarConditionalSentMaterielDao.insert(entity);
		return resultBean;
	}
}
